package com.itqf.factory;

import org.springframework.beans.factory.FactoryBean;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/9/28
 * @Time: 上午11:45
 */
public class MyFactoryBean implements FactoryBean {


    /**
     * 返回创建对象
     * @return
     * @throws Exception
     */
    @Override
    public Object getObject() throws Exception {
        System.out.println("getObject ...........");
       // return new Book();
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/myshop",
                "root","admin");
        return connection;

    }

    /**
     * 对象的类型的Class对象
     * @return
     */
    @Override
    public Class<?> getObjectType() {
        //return Book.class;
        return Connection.class;
    }


    /**
     * 创建的对象的是单例多例
     * @return
     */
    @Override
    public boolean isSingleton() {
        return false;
    }
}
